from selenium import webdriver
import time

driver = webdriver.PhantomJS()
driver.get("https://www.douban.com/")
# 输入账号密码
driver.find_element_by_name("form_email").send_keys("15886793886")
driver.find_element_by_name("form_password").send_keys("douban123")
# 模拟点击登录
driver.find_element_by_xpath("//input[@class='bn-submit']").click()
# 等待3秒
time.sleep(3)
# 生成登陆后快照
driver.save_screenshot("douban.png")
with open("douban.html", "w",encoding='utf8') as file:
    file.write(driver.page_source)
driver.quit()
